Internal REDIRECT : $r->is_initial_req() false but $r->main() undef

Internal REDIRECT : $r->is_initial_req() false but $r->main() undef

am 03.05.2010 14:53:23 von bertolini.cedric

--00148530aad10cf1e70485b01407
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi again,

Subrequests are giving me a hard time :) I managed to use is_initial_req()
in my PATH_INFO subrequests, thanks to your previous answer. But I ran into
another subrequest : internal REDIRECT. My problem was that the subrequest
gets a ResponseHandler call, this time, so I need to have it access the
session perl variable used by the main request (I can't tie two variables t=
o
the same Apache::Session::File file because I'm trying to use Transactional
mode).

Initially, I thought that I would be able to use $r->main() to get the main
request and access $r->main()->pnotes() to get my value. But $r->main()
returns undef even though $r->is_initial_req() returns 0 :-(

Sequence :

[Fixup] /perl/script1.pl
[Response] /perl/script1.pl /// prints Location: /perl/script2.pl\n\n and
returns Apache2::Const::REDIRECT
-- no [CleanUp] for /perl/script1.pl here
[Fixup] /perl/script2.pl //// $r->is_initial_req() returns 0 and $r->main(=
)
returns undef

According to the
documentation _main_>,
this shouldn't happen, right?

Is there another way to access the main request ?
Is there another way to share perl variables between a request and its
subrequests ?


Thanks for your time,
C=E9dric Bertolini

--00148530aad10cf1e70485b01407
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi again,

Subre=
quests are giving me a hard time :) I managed to use is_initial_req() in my=
PATH_INFO subrequests, thanks to your previous answer. But I ran into anot=
her subrequest : internal REDIRECT. My problem was that the subrequest gets=
a ResponseHandler call, this time, so I need to have it access the session=
perl variable used by the main request (I can't tie two variables to t=
he same Apache::Session::File file because I'm trying to use Transactio=
nal mode).


Initially, I thought that I would be able to use $r->main() to get t=
he main request and access $r->main()->pnotes() to get my value. But =
$r->main() returns undef even though $r->is_initial_req() returns 0 :=
-(


Sequence :

[Fixup] /perl/script1.p=
l

[Response] /perl/ /// =
prints=A0 Location: /perl/\n\n =
and returns Apache2::Const::REDIRECT

-- no [CleanUp] for /perl/ here=

[Fixup] /perl/=A0 //// $r-&=
gt;is_initial_req() returns 0 and $r->main() returns undef

Accord=
ing to the c.html#C_main_">documentation , this shouldn't happen, right?


Is there another way to access the main request ?
Is there another w=
ay to share perl variables between a request and its subrequests ?

=

Thanks for your time,
C=E9dric Bertolini



--00148530aad10cf1e70485b01407--

Re: Internal REDIRECT : $r->is_initial_req() false but $r->main() undef

am 03.05.2010 15:07:31 von torsten.foertsch

On Monday 03 May 2010 14:53:23 C=E9dric Bertolini wrote:
> Is there another way to access the main request ?
>=20
No, $r->main is the only way to get the main request.

But an internal redirect is a different thing. It is not a subrequest. Henc=
e=20
$r->main is undef.

You are looking for $r->prev. It gives you the req object before to the=20
redirect.

Torsten Förtsch

=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net